﻿/*=====================================================================================
	TASK 6:                                                    {Conditional Statements}
	Write a program that enters the coefficients a, b and c of a quadratic equation
    a*x2 + b*x + c = 0	 and calculates and prints its real roots. Note that quadratic 
    equations may have 0, 1 or 2 real roots. 
=====================================================================================*/

using System;

class QuadricEquation
{
    static void Main()
    {
        Console.Write("Enter a=");
        float a = float.Parse(Console.ReadLine());
        Console.Write("Enter b=");
        float b = float.Parse(Console.ReadLine());
        Console.Write("Enter c=");
        float c = float.Parse(Console.ReadLine());

        float x,x1,x2,D = ((b * b) - (4 * a * c));
        
        if (a == 0)
        {
            Console.WriteLine("The equation isn't quadric");
        }

        else if (D < 0)
        {
            Console.WriteLine("The equation hasn't real roots");
        }
        else if (D==0)
        {
            x = -b / 2 * a;
            Console.WriteLine("The equation has one real root x1,2=-b/2a={0}",x);
        }
        else
        {
            x1 = (float)(-b + Math.Sqrt(D)) /( 2 * a);
            x2 = (float)(-b - Math.Sqrt(D)) / (2 * a);
            Console.WriteLine("The equation has two real roots:\n x1={0} and x2={1}\n",x1,x2);
        }
    }
}

